package com.sb.framework.util;

import java.io.UnsupportedEncodingException;

import org.apache.tomcat.util.codec.binary.Base64;

public class Base64Utils {

	private static final String CHARSET = "UTF-8";

	/**
	 * 
	 * 使用Base64加密算法加密字符串 return
	 */
	public static String encodeStr(String plainText) {
		try {
			return new String( Base64.encodeBase64( plainText.getBytes( CHARSET ), true ) );
		} catch (UnsupportedEncodingException e) {

		}
		return "";
	}

	/**
	 * 
	 * TODO 使用Base64解密 return
	 */
	public static String decodeStr(String encodeStr) {
		try {
			return new String( Base64.decodeBase64( encodeStr.getBytes( CHARSET ) ) );
		} catch (UnsupportedEncodingException e) {

		}
		return "";
	}
}
